package project.ia04.agents.gui;

import project.ia04.utils.Data;
import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;

public class StepExchangeBehaviour extends CyclicBehaviour {

	@Override
	public void action() {
		MessageTemplate template = MessageTemplate.and(MessageTemplate.MatchPerformative(ACLMessage.REQUEST),
													MessageTemplate.or(MessageTemplate.MatchConversationId(Data.STEP1),
													MessageTemplate.or(MessageTemplate.MatchConversationId(Data.STEP2),
																		MessageTemplate.MatchConversationId(Data.STEP3)
																	))
													);
		ACLMessage message = myAgent.receive(template);
		if(message != null){
			System.out.println("XAgent --> StepExchangeBehaviour \""+message.getConversationId()+"\"");
			((XAgent)myAgent).initStep(message.getConversationId());
		}
		else
			block();
		
	}
}
